package phoenix.core.helpers.extensions;

import phoenix.core.PhoenixManager;
import phoenix.core.base.TestSuiteBase;
import core.ApplicationManager;
import core.helpers.LoggerHelper;

/**
 * Class provides methods for working with logger
 */
public class LoggerHelperExt extends LoggerHelper
{
	// PhoenixManager instance
	protected static PhoenixManager phoenix;

	/**
	 * Initializes LoggerHelperExt
	 * @param p_manager ApplicationManager instance
	 * @param p_phoenix PhoenixManager instance
	 */
	public LoggerHelperExt(ApplicationManager p_manager, PhoenixManager p_phoenix)
	{
		super(p_manager);
		phoenix = p_phoenix;
	}

	/**
	 * Outputs WARNING message to console and writes it to collector, takes a screenshot
	 * @param p_message Message text
	 */
	public void warnAndScreenshot(String p_message)
	{
		warnAndScreenshot(p_message, System.getProperty("user.dir")
				+ "\\reports"
				+ "\\" + TestSuiteBase.TEST_SUITE_NAME
				+ "\\" + TestSuiteBase.TEST_SUITE_DATE
				+ "\\" + TestSuiteBase.TEST_SUITE_TIME
				+ "\\" + TestSuiteBase.TEST_PHASE_NAME + "_" + phoenix.cronos().getCurrentTime("HH-mm-ss") + ".png");
	}

	/**
	 * Outputs ERROR message to console and writes it to collector, takes a screenshot
	 * @param p_message Message text
	 */
	public void errorAndScreen(String p_message)
	{
		this.errorAndScreen(p_message, ApplicationManager.TEST_SCREENSHOT_PATH);

		if (phoenix.config().REDMINE_POST_ERRORS)
		{
			phoenix.redmine().addAttachment(ApplicationManager.TEST_SCREENSHOT_PATH, ApplicationManager.TEST_SCREENSHOT_FILENAME, "image/jpeg");
		}
	}

}
